<!DOCTYPE html>
<html lang="en">

<head>                                                             
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="dk">
        <ul>
            <h3>小黑的书架</h3>
            <li v-for="(item,index) in list" :key="item.id">
                <span>{{item.name}}</span>
                <span>{{item.author}}</span>
                <button @click="del(item,id)">删除</button>
                <!-- 账户:<input type="text" v-model="username"><br>
                密码:<input type="text" v-model="password"><br>
                <button @click="login">登录</button>
                <button @click="reset"> 重置</button> -->
            </li>
        </ul>
    </div>
    <script src="./vue.js"></script>

    <script>
        const dk = new Vue({
            el: "#dk",                                                 
            data: {
                // username:"",
                // password:""
                list:
                    [{ id: 1, name: "《红楼梦》", author: "曹雪芹" },
                    { id: 2, name: "《西游记》", author: " 吴承恩" },
                    { id: 3, name: "《水浒传》", author: "施耐庵" },   
                    { id: 4, name: "《三国演义》", author: "罗贯中" }
                    ]
            },
            // methods:{
            //     login(){
            //         console.log(this.username,this.password);
                    
            //     },
            //     reset(){
            //         this.username="",
            //         this.password=""
            //     }
            // }
            methods:{
                del(id){
                        this.list=this.list.filter(item => item != id)
                }
            }
        })
    </script>
</body>

</html>